//package com.xfz.dao;
//
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.jdbc.core.BeanPropertyRowMapper;
//import org.springframework.jdbc.core.JdbcTemplate;
//import org.springframework.stereotype.Component;
//import java.util.List;
//import com.xfz.User.User;
//@Component
//public class UserDb {
//
//    @Autowired
//    JdbcTemplate template;
//
////    /**
////     * 查询所有
////     * @return
////     */
////    public List<User> selectList(){
////        List<User> userlist=template.query("select * from user",new BeanPropertyRowMapper<>(User.class));
////          return  userlist;
////    }
////
////    /**
////     * 查询id所属字段
////     * @return
////     */
////    public User selectListId(Integer id){
////        User userlist=template.queryForObject("select * from user where id=?",new BeanPropertyRowMapper<>(User.class),id);
////        return  userlist;
////    }
////
////
////    /**
////     * 创建用户
////     *
////     * @param user 用户实体
////     * @return 创建成功：true，删除失败：false
////     */
////    public boolean insertUser(User user) {
////        return template.update("insert into user (name) values (?)", user.getName()) > 0;
////    }
////
////    /**
////     * 根据ID删除用户
////     *
////     * @param id 用户ID
////     * @return 删除成功：true，删除失败：false
////     */
////    public boolean deleteUserById(Integer id) {
////        return template.update("delete from user where id = ?", id) > 0;
////    }
////
////    /**
////     * 修改用户信息
////     *
////     * @param user 用户实体
////     * @return 修改成功：true，修改失败：false
////     */
////    public boolean updateUser(User user) {
////        return template.update("update user set name = ? where id = ?",  user.getName(),user.getId()) > 0;
////    }
//public User getUserByAccount(String account) {
//    try {
//        return template.queryForObject("select * from t_user where account = ?",
//                new BeanPropertyRowMapper<>(User.class),
//                account);
//    } catch (Exception e) {
//        return null;
//    }
//}
//
//    public boolean saveUser(User user) {
//        return template.update("insert into t_user (name, account, password) values (?, ?, ?)",
//                user.getName(), user.getAccount(), user.getPassword()) > 0;
//    }
//    public boolean tokenAdd(String token,Integer id) {
//        return template.update("update t_user set token=? where id=?",token,id )>0;
//
//    }
//    public User getUserByToken(String token) {
//        try {
//            return template.queryForObject("select * from t_user where token = ?",
//                    new BeanPropertyRowMapper<>(User.class),
//                    token);
//        } catch (Exception e) {
//            return null;
//        }
//    }
//
//}
